package cn.edu.xmu.restfuldemo.dao;

import cn.edu.xmu.restfuldemo.mapper.GoodsSkuPoMapper;
import cn.edu.xmu.restfuldemo.mapper.GoodsSkuPoMapper1;
import cn.edu.xmu.restfuldemo.model.BO.GoodsSku;
import cn.edu.xmu.restfuldemo.model.PO.GoodsSkuPo;
import cn.edu.xmu.restfuldemo.model.VO.GoodsSkuVo;
import cn.edu.xmu.restfuldemo.model.VO.OrderWithItemsSkuRetVo;
import cn.edu.xmu.restfuldemo.util.ReturnObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * @author Zijun Min
 * @description
 * @createTime 2021/10/22 16:52
 **/
@Repository
public class GoodsSkuDao {
    @Autowired
    private GoodsSkuPoMapper goodsSkuPoMapper;

    @Autowired
    private GoodsSkuPoMapper1 goodsSkuPoMapper1;

    public ReturnObject<GoodsSku> findGoodsSkuByOrderId(Long id){
        GoodsSkuPo goodsSkuPo= goodsSkuPoMapper.selectByPrimaryKey(id);
        GoodsSkuVo goodsSkuVo=new GoodsSkuVo(goodsSkuPo);
        return new ReturnObject<>(goodsSkuVo.newGoodsSku());
    }

    public ReturnObject<OrderWithItemsSkuRetVo> findGoodsSkuByOrderIdSql(Long orderId){
        OrderWithItemsSkuRetVo orderWithItemsSkuRetVo=goodsSkuPoMapper1.selectByOrderId(orderId);
        return new ReturnObject<>(orderWithItemsSkuRetVo);
    }

}
